<?php
namespace app\common\controller;
use think\db;


class Auth
{

    public function check($uid,$rules)
    {
        $sql = 'SELECT gid FROM Auth_group_access WHERE uid REGEXP '.$uid;
        $data = Db::query($sql);
        if (count($data) == 0) return false;

        $sql = 'SELECT * FROM Auth_group WHERE rules REGEXP'.$rules.'AND gid =';

        foreach ($data as $val) {

            $d = Db::query($sql.$val['gid']);

            if (count($d)) return true;
        }

        return false;

    }

}
